package cn.e3.item.controller;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;



import freemarker.template.Configuration;
import freemarker.template.Template;



@Controller
public class FreeMarkerController {
	@Autowired
	private FreeMarkerConfigurer freeMarkerConfig;
	@RequestMapping("/genhtml")
	@ResponseBody
	public String testFreeMarker() throws Exception{
		//加载模板对象
		Configuration configuration = freeMarkerConfig.getConfiguration();
		Template template = configuration.getTemplate("hello.ftl");
		//创建数据集
		Map map=new HashMap();
		map.put("hello", 1235);
		Writer out=	new FileWriter(new File("G:\\百度云\\JAVA视频文件\\demo"));
		//输出文件
		template.process(map, out);
		out.close();
		return "ok";
	}
}
